/**
 * 
 */
package com.css.crm.utility;

import java.util.Date;

import com.css.crm.vo.AbstractUser;
import com.css.crm.vo.AuditTrailVo;

/**
 * @author AIS
 *
 */
public class AuditTrailUtil {

	/**
	 * get delete operation object
	 * @param auditTrail
	 * @return
	 */
	public static AuditTrailVo getDeleteAuditTrail(AuditTrailVo auditTrail){
		if(auditTrail == null){
			return auditTrail;
		}
		
		auditTrail.setDmlCde(ConstantUtil.DML_CDE_DELETE);
		AbstractUser user = (AbstractUser)SystemUtil.getSession(ConstantUtil.SESSION_USER_KEY);
		if(user != null){
			auditTrail.setBckupUser(user.getSmUserId());
		}else {
			//hard code for test
			auditTrail.setBckupUser("YLB");
		}		
		auditTrail.setBckupDte(new Date());
		
		return auditTrail;
	}
	
	/**
	 * get update operation object
	 * @param auditTrail
	 * @return
	 */
	public static AuditTrailVo getUpdateAuditTrail(AuditTrailVo auditTrail){
		if(auditTrail == null){
			return auditTrail;
		}
		
		auditTrail.setDmlCde(ConstantUtil.DML_CDE_UPDATE);
		AbstractUser user = (AbstractUser)SystemUtil.getSession(ConstantUtil.SESSION_USER_KEY);
		if(user != null){
			auditTrail.setBckupUser(user.getSmUserId());
		}else {
			//hard code for test
			auditTrail.setBckupUser("YLB");
		}	
		auditTrail.setBckupDte(new Date());
		
		return auditTrail;
	}
}
